package com.rn.gypsophila.rabbitmq.mq;

import com.rabbitmq.client.Channel;
import com.rn.gypsophila.rabbitmq.EventMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.stereotype.Component;

import static com.rn.gypsophila.rabbitmq.config.RabbitmqConfig.BIZ_QUEUE;

/**
 * Description: 消息消费者
 *
 * @author rannuo
 * @date 2021/4/10
 */
@Slf4j
@Component
public class TxMessageConsumer extends AbstractTxMessageConsumer {

	@RabbitListener(queues = BIZ_QUEUE)
	@Override
	public void onMessage(Message message, Channel channel) throws Exception {
		super.onMessage(message, channel);
	}

	@Override
	public void receiveMessage(Message message, MessageConverter messageConverter) {
		EventMessage eventMessage = (EventMessage) messageConverter.fromMessage(message);
		log.info("接收到消息{}", eventMessage.toString());
	}

}
